//--------------------------------------------------------------
//
// Qizhi Zhang 
// ezhung@gmail.com
// http://www.moorwind.com
//
//--------------------------------------------------------------
package reader.core
{
	import __AS3__.vec.Vector;
	
	import flash.utils.Dictionary;
	
	import reader.dao.DAOFactory;
	import reader.dao.SqliteDAOFactory;
	import reader.model.factory.ProxyFactory;
	import reader.model.factory.SqliteProxyFactory;
	import reader.model.vo.BlogLabelVO;
	import reader.model.vo.BlogSourceVO;
	import reader.model.vo.ServiceVO;
	import reader.model.vo.UserVO;
	
	public class ReaderModelLocator
	{
		////////////////////////////////////////////////////////////////////////////////
		//application setting
		
		//
		public static const APP_TYPE_AIR:String = "air";
		public static const APP_TYPE_SWF:String = "swf";
		public static var appType:String = "air";
		public var culture:String;
		public var airReader:Reader;
		public var subscribeConfig:XML;
		public var updatePath:String;
		public var onlineHelp:String;
		
		//
		public static const WINDOW_SETTING_PANEL:String = "windowSettingPanel";
		public static const WINDOW_WRITER_PANEL:String = "windowWriterPanel";
		public static const WINDOW_INSERT_PHOTO_PANEL:String = "windowInsertPhotoPanel";
		public static const WINDOW_OAUTH_PANEL:String = "windowOAuthPanel";
		public static const WINDOW_AIR_EXPLORER:String = "windowAirExplorer";
		
		//
		public static const EDITOR_PATH:String = "fckeditor/reader/editor.html";
		public static const CONFIG_PATH:String = "resource/config.inf";
		public static const FEED_CONFIG_PATH:String = "resource/subscribe.config";
		
		public static const HTML_HEADER:String = "<HTML><HEAD><META http-equiv=Content-Type content=\"text\/html;charset=utf-8\"><\/HEAD><BODY STYLE=\"font-size:12px\">";
        public static const HTML_ROOT:String = "<\/BODY><\/HTML>";
        
        //
        public static const MAX_SUMMARY_ITEMS:int = 5;
        public static const MAX_SUMMARY_TEXT:int = 128;
        
        //
        public static const DEBUG_USER:int = 1;
    	
		//
		public const sqliteDAOFactory:SqliteDAOFactory = DAOFactory.getDAOFactory(DAOFactory.SQLITE) as SqliteDAOFactory;
		public const sqliteProxyFactory:SqliteProxyFactory = ProxyFactory.getProxyFactory(ProxyFactory.APP_SQLITE) as SqliteProxyFactory;
		
		////////////////////////////////////////////////////////////////////////////////
		//application variables
						
		[Bindable]
		public var blogSource:Vector.<BlogSourceVO>;
		
		[Bindable]
		public var user:UserVO;
		
		[Bindable]
		public var blogLabels:Vector.<BlogLabelVO>;
		
		public var services:Vector.<ServiceVO>;
		public var adCallBack:String = "http://www.moorwind.com/reader";
		public var feedDictionary:Dictionary/* of BlogItemVO */ = new Dictionary();
		public var labelTotal:Dictionary/* of uint */ = new Dictionary();
		
		public function clear():void
		{
			blogSource = null;
			blogLabels = null;
			services = null;
			feedDictionary = new Dictionary();
			labelTotal = new Dictionary();
			user = null;
		}
		
		////////////////////////////////////////////////////////////////////////////////
		//Single-ton setting
		
		private static var _instance:ReaderModelLocator;
			
		public function ReaderModelLocator(access:Privace)
		{
			if(access)
				if(_instance == null) _instance = this;
			else throw new ReaderError(ReaderError.MANAGER_ERROR);
		}	
			
		public static function get instance():ReaderModelLocator
		{
			if(_instance == null) _instance = new ReaderModelLocator(new Privace);
			return _instance;
		}
	}
}
class Privace{}